<?php
/**
 * Created by PhpStorm.
 * User: SUNHUATAO
 * Desc:前台留言控制器
 */
namespace App\Modules\Home\Http\Controllers;

use App\Http\Controllers\BasicController;
use App\Modules\Manage\Model\MessageModel;
use Illuminate\Http\Request;
class MessageController extends BasicController
{
    public function __construct()
    {
        parent::__construct();
        $this->initTheme('home');
    }
    public function message()
    {
        $this->theme->setTitle('留言反馈');
        return $this->theme->scope('home/message')->render();
    }
    public function addMessage(Request $request)
    {
        //$data = unserialize($_POST);
        $data = $request->except('_token');
        //unset($data['_token']);
        $data['create_time'] = date('Y-m-d H:i:s',time());
        $res = MessageModel::create($data);
        if($res)
        {
            return json_encode('提交成功');
            //return redirect()->back()->with("提交成功");
        }else{
            return json_encode('提交失败');
            //return redirect()->back();
        }
    }
}